<template>
  <div class="page messageMarketing" v-if="isOpen">
    <div class="scroll-view">
      <customHeader middleTitle="短信推广" @leftCallBack="handleBack" />
      <div class="page-body">
        <div class="top">
          <div class="title">短信剩余(条)</div>
          <div class="num">{{msgNum }}</div>
          <div class="charge-btn" @click="linkToMall('/mallList',{tabIndex:0})">充值</div>
        </div>
        <ul class="form-style">
          <li @click="linkTo('/messageMarketing/sendMessage')">
            <span>
              <i class="zhk-fsdx"></i>发送短信
            </span>
            <div>
              <i class="zhk-list_rarrow"></i>
            </div>
          </li>
          <li @click="linkTo('/messageMarketing/sendRecord')">
            <span>
              <i class="zhk-fsju"></i>发送记录
            </span>
            <div>
              <i class="zhk-list_rarrow"></i>
            </div>
          </li>
          <li @click="linkTo('/messageMarketing/signManage')">
            <span>
              <i class="zhk-qmgl"></i>签名管理
            </span>
            <div>
              <i class="zhk-list_rarrow"></i>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import customHeader from "../../components/header/header";
import { Toast } from "mint-ui";
import jsBridge from "../../tools/jsBridge.js";
export default {
  name: "messageMarketing",
  data() {
    return {
      msgNum: 0,
      isOpen: false,//是否开通短信营销
      data: null,
    };
  },
  methods: {
    handleBack() {
      jsBridge.closeWindow();
    },
    linkToMall(url, query) {
      if (query) {
        this.$router.push({ path: url,query:query });
      } else {
        this.$router.push({ path: url });
      }
      sessionStorage.setItem("mallTabIndex",0);
    },
    linkTo(url, query) {
      if (query) {
        this.$router.push({ path: url,query:query });
      } else {
        this.$router.push({ path: url });
      }

    },
    queryAccount() {
      this.ajax({
        url: "/newapp/smsmarketing/queryAccount.do",
        type: "get",
        controlLoading: false
      })
        .then(res => {
          if (res.success) {
            if (res.resultObject) {
              this.data = res.resultObject;
              this.isOpen = res.resultObject.status == 1 ? true : false;//'当前状态，1：有效，0：失效'
              this.msgNum = res.resultObject.msgNum;
              if (!this.isOpen) {
                this.$router.push({ path: "/openMessageMarketing", query: { close: true } });
              }
            } else {
              this.isOpen = false;
              this.$router.push({ path: "/openMessageMarketing", query: { close: true } });
            }
          } else {
            Toast(res.msg);
          }
        })
        .catch(function (err) {

        });
    },
  },
  computed: {

  },
  created() {
    this.queryAccount();
  },

  components: {
    customHeader,
  }
};
</script>
<style lang="scss" scoped>
@import "messageMarketing";
</style>